package org.alala.user.service.impl;

import java.io.IOException;
import java.util.List;

import org.alala.user.common.dao.user.UserDao;
import org.alala.user.data.models.User;
import org.alala.user.service.api.UserService;
import org.alala.user.service.core.ServiceAdapter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.alibaba.dubbo.common.json.JSON;

@Service("userService")
public class UserServiceImpl extends ServiceAdapter implements UserService {

	private static Logger logger = LoggerFactory.getLogger(UserServiceImpl.class);
	
	@Autowired
	private UserDao userDao;

	@Override
	public List<User> search(String name) {
		
		return userDao.search(name);
	}

	@Override
	public int save(User user) {
		try {
			logger.info("保存用户:" + JSON.json(user));
		} catch (IOException e) {
			logger.error("json error", e);
		}
		return userDao.add(user);
		
	}

}
